import 'package:flutter_model_package/parse_base.dart';
import 'package:parse_server_sdk/parse_server_sdk.dart';
/**
 * 課程分類
 */

class CourseCategory extends MSParseBase {
  CourseCategory() : super("CourseCategory");
  CourseCategory.cloe() : this();

  @override
  CourseCategory clone(Map<String, dynamic> map) => CourseCategory.cloe()..fromJson(map);

  static Future<List<CourseCategory>> getCategoryAll() async {
    var query = QueryBuilder(CourseCategory());
    var rep = await query.query();
    return rep.results.map((e) => e).toList();
  }
  static QueryBuilder<CourseCategory> getall(){
    return QueryBuilder(CourseCategory());
  }
  static QueryBuilder<CourseCategory> forCategoryTitle(String title){
    return QueryBuilder(CourseCategory())..whereEqualTo("title", title);
  }

  static Future<List<CourseCategory>> getCategories() async{
    var q = QueryBuilder(CourseCategory());
    var rep = await q.query();
    if(rep.results.isNotEmpty&&rep.success){
      return rep.results.map((e) => e as CourseCategory).toList();
    }
    return List.empty();
  }

}